import { CommanderStatic } from 'commander';
import { IAction } from '../../actions';

/**
 * 命令基类
 *
 * @author chitanda
 * @date 2021-04-18 13:04:55
 * @export
 * @abstract
 * @class CommandBase
 */
export abstract class CommandBase {
  /**
   * 处理行为
   *
   * @author chitanda
   * @date 2021-04-18 13:04:25
   * @protected
   * @type {IAction}
   */
  protected action: IAction;

  /**
   * Creates an instance of CommandBase.
   * @author chitanda
   * @date 2021-04-18 13:04:21
   */
  constructor(program: CommanderStatic) {
    this.action = this.getAction();
    this.load(program);
  }

  /**
   * 加载命令
   *
   * @author chitanda
   * @date 2021-04-18 13:04:43
   * @abstract
   * @param {CommanderStatic} program
   */
  protected abstract load(program: CommanderStatic): void;

  /**
   * 生成行为
   *
   * @author chitanda
   * @date 2021-04-18 13:04:04
   * @protected
   * @abstract
   * @return {*}  {IAction}
   */
  protected abstract getAction(): IAction;
}
